# -*- coding: utf-8 -*-
"""
Utilities/Tornado Autoreload/test01.py
"""
import tornado.web
import tornado.autoreload
import asyncio
import os


class IndexHandler(tornado.web.RequestHandler):
    def get(self):
        r_message = f"This is get method."
        self.finish(r_message)


def reload_hook():
    print(f"This is process auto reload.")


async def main():
    static_path = os.path.join(os.getcwd(), "static")
    template_path = os.path.join(os.getcwd(), "static")
    settings = {
        'static_path': static_path,
        'template_path': template_path
    }
    app = tornado.web.Application([
        (r'/', IndexHandler)
    ], **settings)
    app.listen(8888)
    tornado.autoreload.add_reload_hook(reload_hook)
    tornado.autoreload.watch("static/test01.html")
    tornado.autoreload.start()
    await asyncio.Event().wait()


if __name__ == '__main__':
    asyncio.run(main())
